İki konum arası koordinat bazlı konum arasındaki mesafeyi bulma

Verilen iki koordinat bazlı konum arasındaki mesafeyi bulan C# metodu.
Metodumuz şu şekilde olmalıdır

public static double Calculate(double sLatitude,double sLongitude, double eLatitude, 
                               
double eLongitude){
   
var sLatitudeRadians = sLatitude * (Math.PI / 180.0);
   
var sLongitudeRadians = sLongitude * (Math.PI / 180.0);
   
var eLatitudeRadians = eLatitude * (Math.PI / 180.0);
   
var eLongitudeRadians = eLongitude * (Math.PI / 180.0);

   
var dLongitude = eLongitudeRadians - sLongitudeRadians;
   
var dLatitude = eLatitudeRadians - sLatitudeRadians;

   
var result1 = Math.Pow(Math.Sin(dLatitude / 2.0), 2.0) + 
                 
Math.Cos(sLatitudeRadians) * Math.Cos(eLatitudeRadians) * 
                 
Math.Pow(Math.Sin(dLongitude / 2.0), 2.0);

   
// Using 3956 as the number of miles around the earth
   
var result2 = 3956.0 * 2.0 * 
                 
Math.Atan2(Math.Sqrt(result1), Math.Sqrt(1.0 - result1));

   
return result2;}
  



Yorum :
Sende yorum kat..